<html>

<head>
<style type="text/css">
body
{
	margin:1px;
	
}
.cUserNameSend
{
	font: 12px Arial, Tahoma, Sans-Serif;
	color: rgb(211,89,0);
}
.cUserNameReceive
{
	font: 12px Arial, Tahoma, Sans-Serif;
	color: rgb(1,99,179);
}
.cSentText
{
	font: 14px Arial, Tahoma, Sans-Serif;
	color: rgb(0, 0, 0);
}
.cTimestamp
{
	display:inline;
}

#txtNotify
{
	position: relative;
}
#txtHistory
{
	height: auto;
	width: 99%;

	background-color: rgb(255, 255, 255);
	position: relative;
	margin:0 auto;
	word-wrap: break-word;
	padding-left: 2px;
	padding-right: 2px;
	visibility: visible;
	font: 14px Arial, Tahoma, Sans-Serif;
	color: rgb(103,119,136);
}
#txtNotify
{
	top:-4px;
}

</style>

<script type="text/javascript" language="JavaScript">
	var oNotifyTimer;
	var oDefaultFont = "italic 18px Calibri";
	
	function addMessage(fullName, messageText, messageFont, isSender)
	{
		var oTxtHistory = document.getElementById("txtHistory");
		var oSpanSend	= document.createElement("span");	
		var oSpanUser	= document.createElement("span");
		var oSpanText	= document.createElement("span");
		var oBr			= document.createElement("br");
		var d = new Date();
		var curr_hour = d.getHours();
		var curr_min = d.getMinutes(); // todo - format date HH:MM
		
		if (messageFont == "") messageFont = oDefaultFont;
		
		oSpanUser.innerHTML = "<span class=cTimestamp>[" + curr_hour + ":" + curr_min + "] </span>" + fullName + ": ";
		oSpanUser.className = isSender ? "cUserNameSend" : "cUserNameReceive";
		oSpanText.innerHTML = ParseEmoticons(messageText)
		oSpanText.className = "cSentText";
		oSpanText.style.font = messageFont;
		oSpanSend.appendChild(oSpanUser);
		oSpanSend.appendChild(oSpanText);
		oSpanSend.appendChild(oBr);
		oTxtHistory.appendChild(oSpanSend);
		//oTxtHistory.scrollTop = 999999;
		
		window.scrollBy(0, getHeight(oSpanSend) + 3);
		return oSpanSend;
	}
	
	function getHeight(oElement)
	{
		var oChilds = oElement.children;
		var max = 0;
		for(var i = 0; i<oChilds.length; i++)
			if(oChilds[i].offsetHeight > max)
				max = oChilds[i].offsetHeight;
		if(oElement.offsetHeight > max)
			max = oElement.offsetHeight;
		return max;
	}
	
	function notify(fullName)
	{
		clearTimeout(oNotifyTimer);
		var oTxtHistory = document.getElementById("txtHistory");
		var oTxtNotify = document.getElementById("txtNotify");
		
		if (fullName.length > 0)
		{
			oTxtHistory.style.marginBottom = "5px";
			oTxtNotify.innerHTML = fullName + " is typing...";
			oNotifyTimer = setTimeout("notify(\"\")",3000);
		}
		else
		{
			oTxtHistory.style.marginBottom = "0px";
			oTxtNotify.innerHTML = "";
		}
	}
	function sendCodeRequestOwner(fullName)
	{
		var msg = "You have invited " + fullName + " to start code sharing.";
		alert(msg);
	}
	function sendCodeRequest(fullName)
	{
		var msg = fullName + " is inviting you to start code sharing.";
		codeRequestAnswer(confirm(msg));
	}
	function codeRequestAnswer(accepted)
	{
		//alert(accepted ? "da" : "nu");
	}
	
	
	
	function ParseEmoticons(str)
	{
		//str = str.replace(/:\(fight\)/gi,'<img height="18" src="Emoticons/117.gif" style="height: 18px;">');
	    var path = 'emoticons/';
	    var leftStr = '<img height="18" src="' + path;
	    var rightStr = '" style="height: 18px;">'

	    str = str.replace('<', '&lt;');
	    str = str.replace('>', '&gt;');

	    for (var i = 0; i < 48; i++) {
	        str = str.replace(emoticons[i][0], leftStr + emoticons[i][1] + rightStr);
	        addMessage("asd", leftStr + emoticons[i][1] + rightStr, "", false);
	    }

	    return str;
	}

	var workPath;

	function SetPath(path)
    {
        workPath = path;
    }

	var emoticons;
	function InitEmoticons()
	{
	    emoticons =new Array();
		for (var i = 0; i< 50; i++)
			emoticons[i] = new Array();
		
		emoticons[0][0] = "O:-)"; emoticons[0][1] = "aa.gif";
		emoticons[1][0] = ":-)";  emoticons[1][1] = "ab.gif";
		emoticons[2][0] = ":-(";  emoticons[2][1] = "ac.gif";
		emoticons[3][0] = ";-)";  emoticons[3][1] = "ad.gif";
		emoticons[4][0] = ":-P";  emoticons[4][1] = "ae.gif";
		emoticons[5][0] = "8-)";  emoticons[5][1] = "af.gif";
		emoticons[6][0] = ":-D";  emoticons[6][1] = "ag.gif";
		emoticons[7][0] = ":-[";  emoticons[7][1] = "ah.gif";
		emoticons[8][0] = "=-O";  emoticons[8][1] = "ai.gif";
		emoticons[9][0] = ":-*";  emoticons[9][1] = "aj.gif";
		emoticons[10][0] = ":'("; emoticons[10][1] = "ak.gif";
		emoticons[11][0] = ":-X"; emoticons[11][1] = "al.gif";
		emoticons[12][0] = ":o";  emoticons[12][1] = "am.gif";
		emoticons[13][0] = ":-|"; emoticons[13][1] = "an.gif";
		emoticons[14][0] = ":-\\"; emoticons[14][1] = "ao.gif";
		emoticons[15][0] = "*JOKINGLY*"; emoticons[15][1] = "ap.gif";
		emoticons[16][0] = "]:->"; emoticons[16][1] = "aq.gif";
		emoticons[17][0] = "[:-}"; emoticons[17][1] = "ar.gif";
		emoticons[18][0] = "*KISSED*"; emoticons[18][1] = "as.gif";
		emoticons[19][0] = ":-!"; emoticons[19][1] = "at.gif";
		emoticons[20][0] = "*TIRED*"; emoticons[20][1] = "au.gif";
		emoticons[21][0] = "*STOP*"; emoticons[21][1] = "av.gif";
		emoticons[22][0] = "*KISSING*"; emoticons[22][1] = "aw.gif";
		emoticons[23][0] = "@}->--"; emoticons[23][1] = "ax.gif";
		emoticons[24][0] = "*THUMBS UP*"; emoticons[24][1] = "ay.gif";
		emoticons[25][0] = "*DRINK*"; emoticons[25][1] = "az.gif";
		emoticons[26][0] = "*IN LOVE*";	emoticons[26][1] = "ba.gif";
		emoticons[27][0] = "@=<"; emoticons[27][1] = "bb.gif";
		emoticons[28][0] = "*HELP*"; emoticons[28][1] = "bc.gif";
		emoticons[29][0] = "\m/"; emoticons[29][1] = "bd.gif";
		emoticons[30][0] = "%)"; emoticons[30][1] = "be.gif";
		emoticons[31][0] = "*OK*)";	emoticons[31][1] = "bf.gif";
		emoticons[32][0] = "*SORRY*"; emoticons[32][1] = "bh.gif";
		emoticons[33][0] = "*BRAVO*"; emoticons[33][1] = "bi.gif";
		emoticons[34][0] = "*LOL*"; emoticons[34][1] = "bj.gif";
		emoticons[35][0] = "*PARDON*"; emoticons[35][1] = "bk.gif";
		emoticons[36][0] = "*NO*"; emoticons[36][1] = "bl.gif";
		emoticons[37][0] = "*CRAZY*"; emoticons[37][1] = "bm.gif";
		emoticons[38][0] = "*DONT_KNOW*"; emoticons[38][1] = "bn.gif";
		emoticons[39][0] = "*DANCE*"; emoticons[39][1] = "bo.gif";
		emoticons[40][0] = "*YAHOO*"; emoticons[40][1] = "bp.gif";
		emoticons[41][0] = "*HELLO*"; emoticons[41][1] = "bq.gif";
		emoticons[42][0] = "*BYE*";	emoticons[42][1] = "br.gif";
		emoticons[43][0] = "*YES*";	emoticons[43][1] = "bs.gif";
		emoticons[44][0] = ";D"; emoticons[44][1] = "bt.gif";
		emoticons[45][0] = "*WALL*"; emoticons[45][1] = "bu.gif";
		emoticons[46][0] = "*MAIL*"; emoticons[46][1] = "bv.gif";
		emoticons[47][0] = "*SCRATCH*";	emoticons[47][1] = "bw.gif";
	}
</script>

<body>
	<div id="txtHistory"></div>
	<span id="txtNotify"></span>
	<script type="text/javascript" language="JavaScript">
		InitEmoticons();
	</script>
</body>
</html>
<!-- addMessage("asdsa", "adasd", "italic 18px Calibri", true);
 1C7508F51978 -->